home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / MPW Interfaces & Libraries / PInterfaces / Perf.p < prev    next >
Encoding:
Text File  |  1992-01-29  |  3.6 KB  |  120 lines  |  [TEXT/MPS ]

  1.  
  2. {
  3. Created: Monday, January 22, 1990 at 9:18 PM
  4.     Perf.p
  5.     Pascal Interface to the Macintosh Libraries
  6.  
  7.     Copyright Apple Computer, Inc.    1986-1991
  8.     All rights reserved
  9.     
  10.     DESCRIPTION
  11.     Provides for PC-sampling of User code resources, ROM code, and RAM (misses).
  12.     Produces output text file suitable for input to PerformReport.
  13.     
  14.     Design objectives:
  15.     Language independent, i.e. works with Pascal, C, and Assembly.
  16.     Covers user resources as well as ROM code.
  17.     Memory model independent, i.e. works for Desk Accessories and drivers.
  18.     Uses TimeManager on new ROMs, Vertical Blanking interrupt on 64 K ROMs.
  19.     
  20. }
  21.  
  22.  
  23. {$IFC UNDEFINED UsingIncludes}
  24. {$SETC UsingIncludes := 0}
  25. {$ENDC}
  26.  
  27. {$IFC NOT UsingIncludes}
  28.     UNIT Perf;
  29.     INTERFACE
  30. {$ENDC}
  31.  
  32. {$IFC UNDEFINED UsingPerf}
  33. {$SETC UsingPerf := 1}
  34.  
  35. {$I+}
  36. {$SETC PerfIncludes := UsingIncludes}
  37. {$SETC UsingIncludes := 1}
  38. {$IFC UNDEFINED UsingTypes}
  39. {$I $$Shell(PInterfaces)Types.p}
  40. {$ENDC}
  41. {$SETC UsingIncludes := PerfIncludes}
  42.  
  43. TYPE
  44.  
  45. PLongs = ^ALongs;
  46. ALongs = ARRAY [1..8000] OF LONGINT;
  47.  
  48. PInts = ^AInts;
  49. HInts = ^PInts;
  50.  
  51. AInts = ARRAY [1..8000] OF INTEGER;
  52.  
  53. { PerfGlobals are declared as a record, so main program can allocate
  54. as globals, desk accessory can add to globals allocated via pointer,
  55. print driver can allocate via low memory, etc. }
  56.  
  57.  
  58. TP2PerfGlobals = ^TPerfGlobals;
  59. TPerfGlobals = RECORD
  60.     startROM: LONGINT;            {ROM Base}
  61.     romHits: LONGINT;            {used if MeasureROM is false}
  62.     misses: LONGINT;            {count of PC values outside measured memory}
  63.     segArray: PLongs;            {array of segment handles}
  64.     sizeArray: PLongs;            {array of segment sizes}
  65.     idArray: HInts;             {array of segment rsrc IDs}
  66.     baseArray: PLongs;            {array of offsets to counters for each segment}
  67.     samples: PLongs;            {samples buffer}
  68.     buffSize: LONGINT;            {size of samples buffer in bytes}
  69.     timeInterval: INTEGER;        {number of clock intervals between interrupts}
  70.     bucketSize: INTEGER;        {size of buckets power of 2}
  71.     log2buckSize: INTEGER;        {used in CvtPC}
  72.     pcOffset: INTEGER;            {offset to the user PC at interrupt time.}
  73.     numMeasure: INTEGER;        {# Code segments (w/o jump table)- ROM etc.}
  74.     firstCode: INTEGER;         {index of first Code segment}
  75.     takingSamples: BOOLEAN;     {true if sampling is enabled}
  76.     measureROM: BOOLEAN;
  77.     measureCode: BOOLEAN;
  78.     ramSeg: INTEGER;            {index of "segment" record to cover RAM > 0 if RAM (misses) are to be bucketed.}
  79.     ramBase: LONGINT;            {beginning of RAM being measured.}
  80.     measureRAMbucketSize: INTEGER;
  81.     measureRAMlog2buckSize: INTEGER;
  82.     romVersion: INTEGER;
  83.     vRefNum: INTEGER;            {Volume where the report file is to be created}
  84.     volumeSelected: BOOLEAN;    {True if user selects the report file name}
  85.     rptFileName: Str255;        {Report file name}
  86.     rptFileCreator: Str255;     {Report File Creator}
  87.     rptFileType: Str255;        {Report File type}
  88.     getResType: ResType;        {Resource type}
  89.     END;
  90.  
  91.  
  92.  
  93. FUNCTION InitPerf(VAR thePerfGlobals: TP2PerfGlobals;timerCount: INTEGER;
  94.     codeAndROMBucketSize: INTEGER;doROM: BOOLEAN;doAppCode: BOOLEAN;appCodeType: Str255;
  95.     romID: INTEGER;romName: Str255;doRAM: BOOLEAN;ramLow: LONGINT;ramHigh: LONGINT;
  96.     ramBucketSize: INTEGER): BOOLEAN;
  97. { called once to setup Performance monitoring
  98.  }
  99.  
  100. PROCEDURE TermPerf(thePerfGlobals: TP2PerfGlobals);
  101. { if InitPerf succeeds then TermPerf must be called before terminating program.
  102.  }
  103.  
  104. FUNCTION PerfControl(thePerfGlobals: TP2PerfGlobals;turnOn: BOOLEAN): BOOLEAN;
  105. { Call this to turn off/on measuring.
  106.  Returns previous state.
  107.  }
  108.  
  109. FUNCTION PerfDump(thePerfGlobals: TP2PerfGlobals;reportFile: Str255;doHistogram: BOOLEAN;
  110.     rptFileColumns: INTEGER): INTEGER;
  111. { Call this to dump the statistics into a file. }
  112.  
  113.  
  114. {$ENDC}    { UsingPerf }
  115.  
  116. {$IFC NOT UsingIncludes}
  117.     END.
  118. {$ENDC}
  119.  
  120.